<template>
	<view class="content">
		<u-tabs :list="list" :is-scroll="false" :current="current" @change="change"></u-tabs>
		<view v-if="current==0">
				<view v-for="(item,index) in worktable">
					<view v-if="item.statement=='待提交'">
						<dispensingcard :index2="index"/>
					</view>
				</view>
		</view>
		<view v-if="current==1">
			<view v-for="(item,index) in worktable">
				<view v-if="item.statement=='已开方'">
					<dispensingcard :index2="index"/>
				</view>
			</view>
		</view>
<!-- 		<view v-for="(item,index) in worktable">
			<dispensingcard :index2="index"/>
		</view> -->
		<view class="bottombutton1" @click="adddispensing()">+新增处方</view>
		<view class="bottombutton2" @click="submitdispensing()">提交处方</view>
	</view>
</template>

<script>
	import dispensingcard from '../../component/dispensingcard.vue'
	export default{
		data(){
			return{
				worktable:[],
				list: [{
					name: '待提交',
					count:0
					}, {
					name: '已开方'
					}],
				current: 0
			}
		},
		components:{
			dispensingcard
		},
		methods:{
			toPath(){
				uni.navigateTo({
					url:"doctor_dispensing_detail_medicineinfo"
				})
			},
			change(index) {
				this.current = index;
			},
			adddispensing(){
				getApp().globalData.worktable.push({
					'statement':'待提交',
					'drugs':[]
				})
			},
			submitdispensing(){
				uni.showModal({
					title: '提示',
					content: '是否提交处方？',
					success: function (res) {
					    if (res.confirm) {
							for(var i=0;i<getApp().globalData.worktable.length;i++){
								getApp().globalData.worktable[i].statement='已开方'
							}
							// uni.navigateBack();
							// uni.navigateTo({
							// 	url:"doctor_dispensing_detail_prescription"
							// });
							uni.redirectTo({
								url:"doctor_dispensing_detail_prescription"
							})
						}
					},
				})
			}
		},
		created(){
			this.worktable=getApp().globalData.worktable;
			for(var i=0;i<this.worktable.length;i++){
				if(this.worktable[i].statement=='待提交'){
					this.list[0].count++;
				}
			}
		}
	}
</script>

<style scopped>
	page{
		background-color: #f5f5f5;
	}
	.bottombutton1{
		text-align: center;
		padding: 28rpx;
		font-size: 36rpx;
		width:300rpx;
		position:fixed;
		bottom:0;
		border-radius: 0;
		color: #666666;
		background-color:#ffffff;
		border: 1rpx solid #fff;
	}
	.bottombutton2{
		text-align: center;
		padding: 28rpx;
		margin-left: 300rpx;
		width:500rpx;
		position:fixed;
		bottom:0;
		border-radius: 0;
		color: #FFFFFF;
		background-color:#1477fe;
		font-size: 36rpx;
	}
</style>
